# !/usr/bin/env python3.8
# -*- coding: utf-8 -*-
# @Time : 2021/7/16 11:56
# @Author : minvan
# @Email : jiangming8937@icloud.com
# @File : REo.py
# @Software: PyCharm

account = {
    'username':'test',
    'password':'123'
}

# 如果要在局部函数里改这个全局变量的值，要用global
log_status = {
    'username':None,
    'isLogin':False
}

# 登录装饰器
def login(auth_type):
    """
    :param auth_type: 1.密码登录 2.wechat登录
    """
    def wrapper(f):
        def inner(*args, **kwargs):
            # 如果未登录
            if not log_status['isLogin']:
                if auth_type == 'password':
                    username = input('请输入用户名：')
                    password = input('请输入密码：')
                    if username == account['username'] and password == account['password']:
                        print('登录成功，欢迎 %s' %username)
                        log_status['isLogin'] = True
                        return f(*args, **kwargs)
                    else:
                        print('登录失败')
                else:
                    username = input('输入微信账号：')
                    password = input('输入微信密码：')
                    if username == account['username'] and password == account['password']:
                        print('登录成功，欢迎 %s' %username)
                        log_status['isLogin'] = True
                        return f(*args, **kwargs)
                    else:
                        print('登录失败')

            else:
                return f(*args, **kwargs)

        return inner

    return wrapper

@login('password')
def get_orders():
    print('查询订单列表')


@login('wechat')
def get_balance():
    print('查询余额')

#
# get_orders()
# get_balance()



# check = {'status_code':200,'content':'success'}

class check(object):
    # status_code = 200
    # content = "success"

    @property
    def result(self,status_code,content):
        if self.status_code==200 and self.content == "success":
            print("1")
        else:
            print("2")

if __name__ == '__main__':
    a = check()
    a.result()